# -*- coding: UTF-8 -*-
class Person:
    # 类属性
    personCount = 0;

    # 构造方法
    def __init__(self, name, age):
        Person.personCount += 1;
        self.name = name;
        self.age = age;

    # 类方法
    def displayPersonCount(self):
        print("total person is:%d" % Person.personCount);

    # 类方法
    def displayPerson(self):
        print("person name is:" + self.name + ",age is:" + self.age);

    # 类方法
    def prt(self):
        print(self);
        print(self.__class__);


# 类的实例化以及方法调用
p = Person("cgeb", "10");
p.displayPerson();
p.displayPersonCount();
p.prt();

# get set方法
b = hasattr(p, "age")
g = getattr(p, "age", 100);
setattr(p, "age", 1001);
print(b);
print(g);

# python内置属性
print(Person.__doc__);
print(Person.__dict__);
print(Person.__name__);
print(Person.__module__);


# 垃圾回收  回收没有被引用以及循环引用的对象

class Point:
 def __init__(self,x,y):
     self.x=x;
     self.y=y;
 def __del__(self):
     class_name=self.__class__.__name__;
     print(class_name,"销毁");

p1=Point("x","y");
p2=p1;
p3=p1;
print(id(p1),id(p2),id(p3));
del p1;
del p2;
del p3;
